#!usr/bin/node

const http = require('https'),
      address ='https://www.dm5.com/dm5.ashx?t=1665024094399',
      axios = require('axios'),
      qs = require('querystring'),
      path = require('path'),
      fs = require('fs'),
      body = {
        pagesize: 68,
        pageindex: 1,
        tagid: 0,
        areaid: 0,
        status: 0,
        usergroup: 0,
        pay: -1,
        char:'',
        sort:10,
        action:'getclasscomics'
      },
      total = 3;

var res,data,filename;

async function getPage(page) {
  body.pageindex = page;
  res = await axios.post(address,qs.stringify(body));
  res = res.data;

  return res.data;
}

async function getAllData() {
  for(let i=1;i<40;i++) {
    data = await getPage(i);
    filename = path.join(__dirname,'data',i+'.json');
    fs.writeFileSync(filename,JSON.stringify(data));
  }
}

getAllData();
